package com.asteroid20;

import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;

public class md5 {
    public String newpsd;
    public String switchMD5(String psd){
        newpsd = transToMD5(psd);
        return newpsd;
    }
    private static String transToMD5(String password) {
        try {
            MessageDigest md = MessageDigest.getInstance("md5");
            md.update(password.getBytes());
            BigInteger bigInteger = new BigInteger(1,md.digest());
            return bigInteger.toString(16);
        } catch (NoSuchAlgorithmException e) {
            System.out.println("密码格式错误");
            throw new RuntimeException(e);
        }
    }
}